﻿using Lufei_CaterDAL;
using Lufei_CaterModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lufei_CaterBLL
{
    public class CategoryBLL
    {

        CategoryDAL dal=new CategoryDAL();

        /// <summary>
        /// 查询所有商品类别
        /// </summary>
        /// <returns></returns>
        public List<CategoryInfo> GetCategoryInfos()
        {
            return dal.GetCategories();
        }

        /// <summary>
        /// 根据id查询数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CategoryInfo GetCategoryInfoByID(int id)
        {
          return  dal.GetCategoryInfoByID(id);
        }

        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="ci"></param>
        /// <returns></returns>
        public bool UpdateCategory(CategoryInfo ci)
        {
         return   dal.UpdateCategory(ci)>0;
        }



        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="ci"></param>
        /// <returns></returns>
        public bool InsertCategory(CategoryInfo ci)
        {
            return dal.InsertCategory(ci)>0;
        }

        /// <summary>
        /// 返回商品个数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int GetProductsByCatoryId(int id)
        {
            return Convert.ToInt32(dal.GetProductsByCatoryId(id));
        }


        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SoftDeleteById(int id)
        {
            return dal.SoftDeleteById(id)>0;
        }
    }
}
